package com.zhuoyue.web.controller.system;

import com.zhuoyue.common.core.controller.BaseController;
import com.zhuoyue.common.core.domain.AjaxResult;
import com.zhuoyue.common.core.page.TableDataInfo;
import com.zhuoyue.common.utils.poi.ExcelUtil;
import com.zhuoyue.system.domain.TblUserApiReqCount;
import com.zhuoyue.system.domain.TblAppUserLoginLog;
import com.zhuoyue.system.service.ITblLogManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @author zhanghui
 */
@RestController
@RequestMapping("/system/logManage")
public class TblLogManageController extends BaseController {
    @Autowired
    private ITblLogManageService tblUserLoginMessageService;

    /**
     * 查询用户登录日志列表
     */
    @GetMapping("/userLogin/list")
    public TableDataInfo listUserLogin(TblAppUserLoginLog tblUserLoginMessage) {
        startPage();
        List<TblAppUserLoginLog> list = tblUserLoginMessageService.selectTblUserLoginMessageList(tblUserLoginMessage);
        return getDataTable(list);
    }

    @GetMapping("/userLogin/export")
    public AjaxResult exportUserLogin(TblAppUserLoginLog tblUserLoginMessage) {
        List<TblAppUserLoginLog> list = tblUserLoginMessageService.selectTblUserLoginMessageList(tblUserLoginMessage);
        ExcelUtil<TblAppUserLoginLog> util = new ExcelUtil<>(TblAppUserLoginLog.class);
        return util.exportExcel(list, "用户登录日志");
    }


    /**
     * 查询接口请求统计列表
     */
    @GetMapping("/apiReq/list")
    public TableDataInfo listApiReq(TblUserApiReqCount tblUserReqCount) {
        startPage();
        List<TblUserApiReqCount> list = tblUserLoginMessageService.selectTblUserReqCountList(tblUserReqCount);
        return getDataTable(list);
    }

    /**
     * 导出接口请求统计列表
     */
    @GetMapping("/apiReq/export")
    public AjaxResult exportApiReq(TblUserApiReqCount tblUserReqCount) {
        List<TblUserApiReqCount> list = tblUserLoginMessageService.selectTblUserReqCountList(tblUserReqCount);
        ExcelUtil<TblUserApiReqCount> util = new ExcelUtil<>(TblUserApiReqCount.class);
        return util.exportExcel(list, "接口访问日志");
    }
}
